Gitlab搭建私有库

您所在的位置:网站首页 gitlab 下载项目 Gitlab搭建私有库

Gitlab搭建私有库

2023-05-27 11:57| 来源: 网络整理| 查看: 265

目录

一、前面部分是创建本地库,这里省略

二、发布版本 -- 发布到公司内网

三、发布版本 -- 发布到外网

四、打包framework

五、遇到的错误

一、前面部分是创建本地库,这里省略

有需要的可以参考简书的文章:https://www.jianshu.com/p/7d1533fc6ce7

以下介绍的内容为创建本地私有库后,怎么向远程库发布版本,以期最后可以通过pod search xxx、pod install方式安装自己的远程库到项目;

以及发布远程版本过程中遇到的问题,以及解决方法;

二、发布版本 -- 发布到公司内网 1、创建私有库

在内网 Git 创建一个空的仓库,用来存放私有库;-- 我们这里是网络配置管理帮我们创建好的,这一步省略,有需要的可自行搜索,网上资料很多;

2、提交代码,打tag

(1)克隆这个项目WztFoundation到本地,指令:$ git checkout clone https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation.git

(2)使用命令创建模板项目:$ pod lib create WztFoundation

按照步骤提示,创建模版组件项目;

(3)用 XCode打开 WztFoundation.podspec,进行修改

podspec文件修改并通过校验 ……(略)

(4)提交代码修改

$ git add .

$ git commit -m "WztFoundation first commit"

(5)打tag并推送到gitlab远程私有库

git tag -m "version 0.1.5.9" 0.1.5.9

git push --tags

3、本地检测

指令:

$ pod spec lint WztFoundation.podspec --allow-warnings --verbose --no-clean --use-libraries --skip-import-validation

如果有警告,会导致无法通过,需要添加--allow-warnings 如果使用了 C 函数相关的,需要添加--use-libraries 如果导入的私有库有动态库/静态库,有些C++的代码会导致pod命令编译找不到头文件问题,而真机调试却正常,解决方法:--skip-import-validation

本地检测--指令:

// 本地检测 $ pod lib lint WztFoundation.podspec --allow-warnings --verbose --no-clean --use-libraries --skip-import-validation // 或者使用者一条指令 $ pod spec lint WztFoundation.podspec --allow-warnings --verbose --no-clean --use-libraries --skip-import-validation 4、产生私有库 $ pod repo add WztFoundation 'https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation.git'

把内网仓库 WztFoundation 添加到CocoaPods本地仓库,这步操作会在 ~/.cocoapods/repo 路径下创建一个名字为 WztFoundation 的空文件夹;

指令:

$ pod repo add WztFoundation 'https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation.git' master` $ pod repo push `WztFoundation` WztFoundation.podspec --allow-warnings --verbose --use-libraries --skip-import-validation` 4.1遇到的问题总结:

pod repo add命令后,可以通过pod repo可以查看刚刚添加的本地库信息:

$ pod repo WztFoundation - Type: git (master) - URL: /Users/wzt/.cocoapods/repos/master - Path: /Users/wzt/.cocoapods/repos/WztFoundation WztFoundation https: - Type: file system - URL: - Path: /Users/wzt/.cocoapods/repos/WztFoundation https: master - Type: git (remotes/origin/master) - URL: [https://github.com/CocoaPods/Specs.git](https://github.com/CocoaPods/Specs.git) - Path: /Users/wzt/.cocoapods/repos/master volcengine-volcengine-specs - Type: git (master) - URL: [https://github.com/volcengine/volcengine-specs.git](https://github.com/volcengine/volcengine-specs.git) - Path: /Users/wzt/.cocoapods/repos/volcengine-volcengine-specs

4.1.1 WztFoundation路径下,config文件url为空?

不知道什么原因,只知道url需要修改为我们的远程私有库地址:https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation.git

4.1.2 报错:

Validating spec Cloning spec repo `-1` from `` $ /usr/bin/git clone -- -1 fatal: repository '' does not exist [!] Unable to add a source with url `` named `-1`. (/usr/bin/git clone -- -1 fatal: repository '' does not exist ) You can try adding it manually in `/Users/wzt/.cocoapods/repos` or via `pod repo add`.

以上是报错信息,下方是问题分析及解决方法 :

(1)~/.cocoapods/repos/WztFoundation/config文件下url为https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoudnation.git

再次pod repo push

依然失败...

(2)直到看到这篇资料:https://github.com/CocoaPods/CocoaPods/issues/8315

说是因为pod repo list,有的repo更新失败导致的,需要删掉一些没用的repo,比如一些url为空的repo;

再次执行,成功~

成功后打印: WztFoundation passed validation. Adding the spec to the `SpecRepo' repo $ /usr/bin/git -C /Users/wzt/.cocoapods/repos/SpecRepo status --porcelain - [No change] WztFoundation (0.1.5.9) Pushing the `SpecRepo' repo $ /usr/bin/git -C /Users/wzt/.cocoapods/repos/SpecRepo push origin HEAD To [https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation.git](https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation.git) 1244815..3613322 HEAD -> master 5、项目中引用私有库

在 podfile 文件中添加 source 参考:

source 'https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation.git' source 'https://github.com/CocoaPods/Specs.git' target 'xxxx' do pod 'WztFoundation' end 三、发布版本 -- 发布到外网 1、提交修改 $ git add . $ git commit -m "changes' description" 2、验证本地.podspec 文件的有效性 $ pod lib lint WztFoundation.podspec --allow-warnings --verbose --no-clean --use-libraries --skip-import-validation ##或者 $ pod spec lint WztFoundation.podspec --allow-warnings --verbose --no-clean --use-libraries --skip-import-validation

打印表示成功:WztFoundation passed validation.

3、推到 pod 上 $ pod trunk push WztFoundation.podspec --allow-warnings --verbose --use-libraries --skip-import-validation

成功后打印:

- Log messages: - May 4th, 06:11: Push for `WztFoundation 0.1.5.5' initiated. - May 4th, 06:11: Push for `WztFoundation 0.1.5.5' has been pushed (0.428640813 s). 3.1 error Error: Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.

解决方法--注册 CocoaPods 的 Trunk 服务:

$ pod trunk register [[email protected]](mailto:[email protected]) 'A21001' --verbose

行完以下命令,去邮箱点击 Trunk 验证链接。 查询注册信息。

$ pod trunk me 3.2 error [!] An unexpected error occurred:

解决方法: https://github.com/CocoaPods/CocoaPods/issues/11621 这个问题上说,这一步会有50%的成功概率,要多尝试几次 然后会有概率遇到另外一个错误:"error":"Unable to accept duplicate entry for: WztFoundation (0.1.5.4)"

3.3 error "error\":\"Unable to accept duplicate entry for: WztFoundation (0.1.5.4)\"

解决方法:

$ pod trunk delete WztFoundation 0.1.5.4 --allow-warnings --verbose

然后继续重试~

成功后打印信息:

Push for `WztFoundation 0.1.5.4' has been pushed (0.421013575 s). 4.可以新建一个项目测试一下自己的库是否发布成功

pod search 一下自己的类库

$ pod search WztFoundation

成功打印:

-> WztFoundation (0.1.5.6) A short description of WztFoundation. pod 'WztFoundation', '~> 0.1.5.6' - Homepage: [https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation](https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation) - Source: [https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation.git](https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation.git) - Versions: 0.1.5.6, 0.1.5.5, 0.1.5.4 [master repo] 4.1 error:Unable to find a pod with name, author, summary, or description matching WztFoundation

解决方法:

$ pod setup $ rm -rf ~/Library/Caches/Cocoapods $ pod search WztFoundation 4.2 error

依然报错:Unable to find a pod with name, author, summary, or description matching WztFoundation 解决方法:

cd ~/.cocoapods/repos pod repo remove master pod repo add master [https://github.com/CocoaPods/Specs.git](https://github.com/CocoaPods/Specs.git) pod repo add master https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation.git rm ~/Library/Caches/CocoaPods/search_index.json 四、打包framework

1、pod命令package 2、Xcode项目添加xcodbuild命令

五、遇到的错误

1、创建私有库后,pod install时报Classes和Assets的错误

https://juejin.cn/post/6952753809974099982

2、[!] An unexpected version directory Classes was encountered for the 'xxxx'

或者使用这种方法解决,简单快捷

pod 'WztFoundation', :git => "https://gitlab.wztcom.com/NewEnergy/IOSAPP/WztFoundation.git", :tag => '0.1.6.0'

参考资料:

CocoaPods公有库和私有库制作 https://blog.csdn.net/Johncahong/article/details/123426980

(CocoaPods) - 在内网搭建私有库 https://www.jianshu.com/p/89e22651952f



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3